#include "Camera.h"


const float CIView::Camera::WIDTH = 90.0f;
const float CIView::Camera::HEIGHT = 90.0f;
const float CIView::Camera::ZOOM = 1.8f;
const float CIView::Camera::FOV = 54.0f;

/// <summary>
/// Constructor
/// </summary>
/// <param name="t"> The camera's type </param>
CIView::Camera::Camera (CIView::Camera::CameraType t)
: type(t), vrpDistance(100.0f), zoom(ZOOM), 
  fov(FOV), aspectRatio(1.0f), 
  zNear(0.5f), zFar(200.0f) {
    
    float r1 = WIDTH / 2.0f;
    float r2 = HEIGHT / 2.0f;
    left = -r1;
    right = r1; 
    bottom = -r2;
    top = r2;

    //Setting parameters according to camera's type
    switch (type) {         
        case TOP: 
            orientation.x = 90;
            break;

        //case FRONT:    /* orientation is already ok */
        //    break;

        case RIGHT: 
            orientation.y = 270;
            break;

        case USER:
            orientation.x = 30;
            orientation.y = 330;            
            zoom -= 0.3f;
            break;
    }
}

/// <summary>
/// Destructor
/// </summary>
CIView::Camera::~Camera() {}




/// <summary>
/// Method called to reset the camera parameters
/// </summary>
void CIView::Camera::Reset() {
    vrpDistance = 100.0f;
    zoom = ZOOM; 
    fov = FOV;
    aspectRatio = 1.0f; 
    
    float r1 = WIDTH / 2.0f;
    float r2 = HEIGHT / 2.0f;
    left = -r1;
    right = r1; 
    bottom = -r2;
    top = r2;

    zNear = 0.5f; 
    zFar = 200.0f;

    vrp = CICore::Point();
    orientation = CICore::Orientation();

    switch (type) {         
        case TOP: 
            orientation.x = 90;
            break;

        //case FRONT:    /* orientation is already ok */
        //    break;

        case RIGHT: 
            orientation.y = 270;
            break;

        case USER:
            orientation.x = 30;
            orientation.y = 330;            
            zoom -= 0.3f;
            break;
    }
}
